package org.westos.ChinaSoft3;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class ReadFile {

    public ArrayList<Employee> readFile() throws IOException {
        ArrayList<Employee> list = new ArrayList<>();
        BufferedReader br=null;
        FileReader reader=null;
        try {
            reader = new FileReader("1.txt");
            br = new BufferedReader(reader);
            String line = null;
            while ((line = br.readLine()) != null) {
                if (line == null) {
                    break;
                }
                String[] str = line.split(",");
                Employee emp = new Employee(Integer.valueOf(str[0]), str[1], Integer.valueOf(str[2]), str[3], Integer.valueOf(str[4]));
                list.add(emp);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            reader.close();
            br.close();
        }
        return list;
    }

}
